From 2911af8256327c067ad8ec05ed5054e9812fc06d Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 29 Oct 2010 18:14:01 +0100 Subject: [PATCH] x86 hvm: Introduce unregister_io_handler Signed-off-by: Anthony PERARD Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/intercept.c | 25 +++++++++++++++++++++---- xen/include/asm-x86/hvm/io.h | 9 +++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/intercept.c b/xen/arch/x86/hvm/intercept.c index 4af9e3d112..2d88cc86b0 100644 --- a/xen/arch/x86/hvm/intercept.c +++ b/xen/arch/x86/hvm/intercept.c @@ -237,13 +237,30 @@ void register_io_handler( handler->hdl_list[num].addr = addr; handler->hdl_list[num].size = size; - if ( (handler->hdl_list[num].type = type) == HVM_PORTIO ) - handler->hdl_list[num].action.portio = action; - else - handler->hdl_list[num].action.mmio = action; + handler->hdl_list[num].action.ptr = action; handler->num_slot++; } +void unregister_io_handler( + struct domain *d, unsigned long addr, unsigned long size, int type) +{ + struct hvm_io_handler *handler = &d->arch.hvm_domain.io_handler; + int i; + + for ( i = 0; i < handler->num_slot; i++ ) + if ( (handler->hdl_list[i].addr == addr) && + (handler->hdl_list[i].size == size) && + (handler->hdl_list[i].type == type) ) + goto found; + return; + + found: + memcpy(&handler->hdl_list[i], + &handler->hdl_list[handler->num_slot-1], + sizeof(struct io_handler)); + handler->num_slot--; +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h index c10a0bef2a..8a81bff225 100644 --- a/xen/include/asm-x86/hvm/io.h +++ b/xen/include/asm-x86/hvm/io.h @@ -50,6 +50,7 @@ struct io_handler { union { portio_action_t portio; mmio_action_t mmio; + void *ptr; } action; }; @@ -68,6 +69,8 @@ int hvm_io_intercept(ioreq_t *p, int type); void register_io_handler( struct domain *d, unsigned long addr, unsigned long size, void *action, int type); +void unregister_io_handler( + struct domain *d, unsigned long addr, unsigned long size, int type); static inline int hvm_portio_intercept(ioreq_t *p) { @@ -89,6 +92,12 @@ static inline void register_portio_handler( register_io_handler(d, addr, size, action, HVM_PORTIO); } +static inline void unregister_portio_handler( + struct domain *d, unsigned long addr, unsigned long size) +{ + unregister_io_handler(d, addr, size, HVM_PORTIO); +} + static inline void register_buffered_io_handler( struct domain *d, unsigned long addr, unsigned long size, mmio_action_t action) -- 2.30.2